#ifndef COMMAND_PARSE_H
#define COMMAND_PARSE_H
#include <QObject>



class CommandParse
{
public:
    CommandParse();

    //将数值转换为QByteArray
    static QByteArray IntToArray(unsigned int v);
    static QByteArray ShortToArray(unsigned short v);
    //将QByteArray转换为数值
    static unsigned int ArrayToInt(const QByteArray &in);

    static QByteArray BuildSendData(const quint16 &frame, const unsigned char &camera_id, const unsigned char &cmd, const QByteArray& data);
    static bool ParseCommands(QByteArray &src_data, QList<QByteArray>& list_data);

    //单条命令最小字节数
    static int ReceiveDataMinBytes();
    static bool ParseOneCommand(QByteArray &src_data, QByteArray& parsed_data);
    //获取命令--命令type
    static unsigned char GetCommandId(const QByteArray &command);
    //检查收发命令是否匹配
    static bool CheckMatchCommand(const QByteArray &cmd1, const QByteArray &cmd2);

    static unsigned char GetRecvCode(unsigned char a);
private:
    static unsigned char sumCheck(QByteArray array);
    static unsigned char xorCheck(QByteArray array);
};

#endif // COMMAND_PARSE_H
